package com.transitionseverywhere.utils;

import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import com.transitionseverywhere.R;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

/* loaded from: classes.dex */
public class ViewUtils {
    private static final BaseViewUtils IMPL;

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public static class BaseViewUtils {
        private static final int VIEW_VISIBILITY_MASK = 12;
        private static final Field FIELD_VIEW_FLAGS = ReflectionUtils.getPrivateField(View.class, "mViewFlags");
        private static final Field FIELD_LAYOUT_PARAMS = ReflectionUtils.getPrivateField(View.class, "mLayoutParams");
        private static final Method METHOD_SET_FRAME = ReflectionUtils.getPrivateMethod(View.class, "setFrame", Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE);

        public View addGhostView(View view, ViewGroup viewGroup, Matrix matrix) {
            return null;
        }

        public Rect getClipBounds(View view) {
            return null;
        }

        public float getTranslationZ(View view) {
            return 0.0f;
        }

        public Object getWindowId(View view) {
            return null;
        }

        public boolean hasTransientState(View view) {
            return false;
        }

        public boolean isLaidOut(View view, boolean z) {
            return z;
        }

        public boolean isRtl(View view) {
            return false;
        }

        public void removeGhostView(View view) {
        }

        public void setAnimationMatrix(View view, Matrix matrix) {
        }

        public void setClipBounds(View view, Rect rect) {
        }

        public void setHasTransientState(View view, boolean z) {
        }

        public void setTranslationZ(View view, float f) {
        }

        public void transformMatrixToGlobal(View view, Matrix matrix) {
        }

        public void transformMatrixToLocal(View view, Matrix matrix) {
        }

        BaseViewUtils() {
        }

        public float getTransitionAlpha(View view) {
            return view.getAlpha();
        }

        public void setTransitionName(View view, String str) {
            view.setTag(R.id.transitionName, str);
        }

        public String getTransitionName(View view) {
            return (String) view.getTag(R.id.transitionName);
        }

        public void setTransitionVisibility(View view, int i) {
            ReflectionUtils.setFieldValue(view, FIELD_VIEW_FLAGS, Integer.valueOf(i | (((Integer) ReflectionUtils.getFieldValue(view, 0, FIELD_VIEW_FLAGS)).intValue() & (-13))));
        }

        public void setLeftTopRightBottom(View view, int i, int i2, int i3, int i4) {
            ReflectionUtils.invoke(view, null, METHOD_SET_FRAME, Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i4));
        }

        public void setLayoutParamsSilently(View view, ViewGroup.LayoutParams layoutParams) {
            ReflectionUtils.setFieldValue(view, FIELD_LAYOUT_PARAMS, layoutParams);
        }
    }

    /* loaded from: classes.dex */
    static class ViewUtilsJellyBean extends BaseViewUtils {
        ViewUtilsJellyBean() {
        }

        @Override // com.transitionseverywhere.utils.ViewUtils.BaseViewUtils
        public void setHasTransientState(View view, boolean z) {
            view.setHasTransientState(z);
        }

        @Override // com.transitionseverywhere.utils.ViewUtils.BaseViewUtils
        public boolean hasTransientState(View view) {
            return view.hasTransientState();
        }
    }

    /* loaded from: classes.dex */
    static class ViewUtilsJellyBeanMR1 extends ViewUtilsJellyBean {
        ViewUtilsJellyBeanMR1() {
        }

        @Override // com.transitionseverywhere.utils.ViewUtils.BaseViewUtils
        public boolean isRtl(View view) {
            return view != null && view.getLayoutDirection() == 1;
        }
    }

    /* loaded from: classes.dex */
    static class ViewUtilsJellyBeanMR2 extends ViewUtilsJellyBeanMR1 {
        ViewUtilsJellyBeanMR2() {
        }

        @Override // com.transitionseverywhere.utils.ViewUtils.BaseViewUtils
        public void setClipBounds(View view, Rect rect) {
            view.setClipBounds(rect);
        }

        @Override // com.transitionseverywhere.utils.ViewUtils.BaseViewUtils
        public Rect getClipBounds(View view) {
            return view.getClipBounds();
        }

        @Override // com.transitionseverywhere.utils.ViewUtils.BaseViewUtils
        public Object getWindowId(View view) {
            return view.getWindowId();
        }
    }

    /* loaded from: classes.dex */
    static class ViewUtilsKitKat extends ViewUtilsJellyBeanMR2 {
        @Override // com.transitionseverywhere.utils.ViewUtils.BaseViewUtils
        public boolean isLaidOut(View view, boolean z) {
            return view.isLaidOut();
        }
    }

    static {
        int i = Build.VERSION.SDK_INT;
        if (i >= 22) {
            IMPL = new ViewUtilsLollipopMr1();
        } else if (i >= 21) {
            IMPL = new ViewUtilsLollipop();
        } else if (i >= 19) {
            IMPL = new ViewUtilsKitKat();
        } else if (i >= 18) {
            IMPL = new ViewUtilsJellyBeanMR2();
        } else if (i >= 17) {
            IMPL = new ViewUtilsJellyBeanMR1();
        } else if (i >= 16) {
            IMPL = new ViewUtilsJellyBean();
        } else {
            IMPL = new BaseViewUtils();
        }
    }

    public static float getTransitionAlpha(View view) {
        return IMPL.getTransitionAlpha(view);
    }

    public static boolean isLaidOut(View view, boolean z) {
        return IMPL.isLaidOut(view, z);
    }

    public static void setClipBounds(View view, Rect rect) {
        IMPL.setClipBounds(view, rect);
    }

    public static Rect getClipBounds(View view) {
        return IMPL.getClipBounds(view);
    }

    public static void setTransitionName(View view, String str) {
        IMPL.setTransitionName(view, str);
    }

    public static String getTransitionName(View view) {
        return IMPL.getTransitionName(view);
    }

    public static float getTranslationZ(View view) {
        return IMPL.getTranslationZ(view);
    }

    public static void setTranslationZ(View view, float f) {
        IMPL.setTranslationZ(view, f);
    }

    public static void transformMatrixToGlobal(View view, Matrix matrix) {
        IMPL.transformMatrixToGlobal(view, matrix);
    }

    public static void transformMatrixToLocal(View view, Matrix matrix) {
        IMPL.transformMatrixToLocal(view, matrix);
    }

    public static void setAnimationMatrix(View view, Matrix matrix) {
        IMPL.setAnimationMatrix(view, matrix);
    }

    public static View addGhostView(View view, ViewGroup viewGroup, Matrix matrix) {
        return IMPL.addGhostView(view, viewGroup, matrix);
    }

    public static void removeGhostView(View view) {
        IMPL.removeGhostView(view);
    }

    public static Object getWindowId(View view) {
        return IMPL.getWindowId(view);
    }

    public static boolean isRtl(View view) {
        return IMPL.isRtl(view);
    }

    public static boolean hasTransientState(View view) {
        return IMPL.hasTransientState(view);
    }

    public static void setHasTransientState(View view, boolean z) {
        IMPL.setHasTransientState(view, z);
    }

    public static void setTransitionVisibility(View view, int i) {
        IMPL.setTransitionVisibility(view, i);
    }

    public static void setLeftTopRightBottom(View view, int i, int i2, int i3, int i4) {
        if (view != null) {
            IMPL.setLeftTopRightBottom(view, i, i2, i3, i4);
        }
    }

    public static void setLayoutParamsSilently(View view, ViewGroup.LayoutParams layoutParams) {
        IMPL.setLayoutParamsSilently(view, layoutParams);
    }
}
